﻿<Window x:Class="WPFBehaviorLibrary.Examples.MainTestWindow"
		xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
		xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
		xmlns:Interaction="clr-namespace:System.Windows.Interactivity;assembly=System.Windows.Interactivity"
		xmlns:dd="clr-namespace:WPFBehaviorLibrary.DragDropBehavior;assembly=WPFBehaviorLibrary"
		xmlns:regex="clr-namespace:WPFBehaviorLibrary.RegexTextBoxBehavior;assembly=WPFBehaviorLibrary"
		xmlns:local="clr-namespace:WPFBehaviorLibrary.Examples"
		Title="DragDrop">

	<TabControl>
		<TabItem Header="Drag &amp; Drop Behavior">
			<TabItem.Resources>
				<DataTemplate x:Key="ItemsControlDataTemplate"
							  DataType="{x:Type local:Person}">
					<Border BorderBrush="LightBlue"
							BorderThickness="1"
							Margin="0,0,0,5">
						<TextBlock>
					<TextBlock.Text>
						<MultiBinding StringFormat="{}{0} {1}">
							<Binding Path="FirstName" />
							<Binding Path="LastName" />
						</MultiBinding>
					</TextBlock.Text>
						</TextBlock>
					</Border>
				</DataTemplate>

				<DataTemplate x:Key="ListBoxDataTemplate"
							  DataType="{x:Type local:Person}">
					<StackPanel>
						<TextBlock>
					<TextBlock.Text>
						<MultiBinding StringFormat="{}{0} {1}">
							<Binding Path="FirstName" />
							<Binding Path="LastName" />
						</MultiBinding>
					</TextBlock.Text>
						</TextBlock>
						<TextBlock Text="{Binding PhoneNumber}" />
						<TextBlock Text="{Binding Email}" />
					</StackPanel>
				</DataTemplate>

				<DataTemplate x:Key="TabItemHeaderDataTemplate"
							  DataType="{x:Type local:Person}">
					<TextBlock Text="{Binding FirstName}" />
				</DataTemplate>

				<DataTemplate x:Key="TabItemContentDataTemplate"
							  DataType="{x:Type local:Person}">
					<StackPanel>
						<StackPanel Orientation="Horizontal">
							<TextBlock Margin="0,0,5,0"
									   Text="First Name" />
							<TextBlock Text="{Binding FirstName}" />
						</StackPanel>
						<StackPanel Orientation="Horizontal">
							<TextBlock Margin="0,0,5,0"
									   Text="Last Name" />
							<TextBlock Text="{Binding LastName}" />
						</StackPanel>
						<StackPanel Orientation="Horizontal">
							<TextBlock Margin="0,0,5,0"
									   Text="Phone Number" />
							<TextBlock Text="{Binding PhoneNumber}" />
						</StackPanel>
						<StackPanel Orientation="Horizontal">
							<TextBlock Margin="0,0,5,0"
									   Text="Email" />
							<TextBlock Text="{Binding Email}" />
						</StackPanel>
					</StackPanel>
				</DataTemplate>

				<Style TargetType="{x:Type HeaderedContentControl}">
					<Setter Property="Margin"
							Value="5" />
					<Setter Property="Template">
						<Setter.Value>
							<ControlTemplate TargetType="{x:Type HeaderedContentControl}">
								<DockPanel>
									<ContentPresenter DockPanel.Dock="Top"
													  ContentSource="Header" />
									<ContentPresenter ContentSource="Content" />
								</DockPanel>
							</ControlTemplate>
						</Setter.Value>
					</Setter>
				</Style>

				<Style x:Key="TabItemContainerStyle"
					   TargetType="TabItem">
					<Setter Property="HeaderTemplate"
							Value="{StaticResource TabItemHeaderDataTemplate}" />
					<Setter Property="ContentTemplate"
							Value="{StaticResource TabItemContentDataTemplate}" />
				</Style>
			</TabItem.Resources>

			<DockPanel>
				<TextBlock DockPanel.Dock="Top"
						   HorizontalAlignment="Center"
						   FontSize="24"
						   Margin="10"
						   Text="Drag and drop to move items." />

				<UniformGrid>

					<HeaderedContentControl Header="ItemsControl">
						<ItemsControl Margin="5"
									  ItemsSource="{Binding People}"
									  BorderBrush="Black"
									  BorderThickness="1"
									  ItemTemplate="{StaticResource ItemsControlDataTemplate}">
							<Interaction:Interaction.Behaviors>
								<dd:DragDropBehavior ItemType="{x:Type local:Person}"
													 DataTemplate="{StaticResource ItemsControlDataTemplate}" />
							</Interaction:Interaction.Behaviors>
						</ItemsControl>
					</HeaderedContentControl>

					<HeaderedContentControl Header="ListBox">
						<ListBox Margin="5"
								 ItemTemplate="{StaticResource ListBoxDataTemplate}">
							<Interaction:Interaction.Behaviors>
								<dd:DragDropBehavior ItemType="{x:Type local:Person}"
													 DataTemplate="{StaticResource ListBoxDataTemplate}" />
							</Interaction:Interaction.Behaviors>
						</ListBox>
					</HeaderedContentControl>

					<HeaderedContentControl Header="TabControl">
						<TabControl Margin="5"
									ItemContainerStyle="{StaticResource TabItemContainerStyle}">
							<Interaction:Interaction.Behaviors>
								<dd:DragDropBehavior ItemType="{x:Type local:Person}"
													 DropIndication="Horizontal"
													 DataTemplate="{StaticResource TabItemHeaderDataTemplate}" />
							</Interaction:Interaction.Behaviors>
						</TabControl>
					</HeaderedContentControl>

					<HeaderedContentControl Header="ListView">
						<ListView Margin="5">
							<Interaction:Interaction.Behaviors>
								<dd:DragDropBehavior ItemType="{x:Type local:Person}">
									<dd:DragDropBehavior.DataTemplate>
										<DataTemplate>
											<TextBlock>
										<TextBlock.Text>
											<MultiBinding StringFormat="{}{0} {1}">
												<Binding Path="FirstName" />
												<Binding Path="LastName" />
											</MultiBinding>
										</TextBlock.Text>
											</TextBlock>
										</DataTemplate>
									</dd:DragDropBehavior.DataTemplate>
								</dd:DragDropBehavior>
							</Interaction:Interaction.Behaviors>

							<ListView.View>
								<GridView AllowsColumnReorder="true">
									<GridViewColumn Header="First Name"
													DisplayMemberBinding="{Binding FirstName}" />

									<GridViewColumn Header="Last Name"
													DisplayMemberBinding="{Binding LastName}" />

									<GridViewColumn Header="Phone Number"
													DisplayMemberBinding="{Binding PhoneNumber}" />

									<GridViewColumn Header="Email"
													DisplayMemberBinding="{Binding Email}" />
								</GridView>
							</ListView.View>
						</ListView>
					</HeaderedContentControl>
				</UniformGrid>

			</DockPanel>
		</TabItem>

		<TabItem Header="Regex Textbox Behavior">
			<StackPanel>
				<HeaderedContentControl Header="Numeric TextBox:">
					<HeaderedContentControl.Content>
						<TextBox HorizontalAlignment="Stretch">
							<Interaction:Interaction.Behaviors>
								<regex:NumericTextBoxBehavior />
							</Interaction:Interaction.Behaviors>
						</TextBox>
					</HeaderedContentControl.Content>
				</HeaderedContentControl>
			</StackPanel>
		</TabItem>
	</TabControl>
</Window>
